package actions;

import gui.GUIWindow;

import java.awt.event.ActionEvent;

import javax.swing.JOptionPane;

import parameters.RlmServerParameters;

@SuppressWarnings("serial")
public class StatusAction extends SysTrayAbstractAction {

	public StatusAction(GUIWindow owner) {
		setActionOwner(owner);
		
//		putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_F7, 0));
//		putValue(SMALL_ICON, ImageCreator.createImageIcon(AboutAction.class, "images/start.png"));
		putValue(NAME, "Status");
		putValue(SHORT_DESCRIPTION, "Status");
		
		setActionItem();
	}

	
	public void actionPerformed(ActionEvent e) {

		boolean startFlag = false;
		
		if ( getActionOwner().getApplication().getRlmServerReference() != null ) {
			startFlag = getActionOwner().getApplication().getRlmServerReference().isStarted();
		}
		
		StringBuffer buffer = new StringBuffer();
		
		buffer.append("RLM Server ");
		if (startFlag == true) {
			buffer.append("STARTED.");
		}
		else {
			buffer.append("STOPPED.");
		}
		buffer.append("\n");
		buffer.append("Server Port: ");
		buffer.append(RlmServerParameters.getServerPort());
		buffer.append(".");
		
		JOptionPane.showMessageDialog(super.getActionOwner(),
				buffer.toString(),
				"Status - RLM Server",
				JOptionPane.INFORMATION_MESSAGE);

	}
	
}
